﻿package com.mui.controls
{
    import com.gengine.core.*;
    import com.gengine.global.*;
    import com.mui.skins.*;
    import com.mui.utils.*;
    import fl.containers.*;
    import fl.core.*;
    import flash.display.*;

    public class GScrollPane extends ScrollPane implements IFrUI
    {
        private var verticalScrollBarPosition:String = "right";
        private var _highPerformance:Boolean;
        public const CLASSNAME:String = "ScrollPane";
        private var _isDisposed:Boolean;
        private var _styleName:String = "";
        private var _isStyleChange:Boolean = false;
        private var verticalScrollBarWidth:Number = 13;
        public static const SCROLLBARPOSITIONLEFT:String = "left";
        public static const SCROLLBARPOSITIONRIGHT:String = "right";

        public function GScrollPane()
        {
            this._styleName = this.CLASSNAME;
            this.tabChildren = false;
            return;
        }// end function

        public function get highPerformance() : Boolean
        {
            return this._highPerformance;
        }// end function

        public function set highPerformance(param1:Boolean) : void
        {
            this.mouseEnabled = !param1;
            this.contentClip.mouseEnabled = !param1;
            this.useBitmapScrolling = param1;
            return;
        }// end function

        public function get styleName() : String
        {
            return this._styleName;
        }// end function

        public function set styleName(param1:String) : void
        {
            if (this._styleName != param1)
            {
                this._styleName = param1;
                invalidate(InvalidationType.STYLES);
                this._isStyleChange = true;
            }
            return;
        }// end function

        override protected function draw() : void
        {
            if (isInvalid(InvalidationType.STYLES))
            {
                if (this._isStyleChange)
                {
                    SkinManager.setComponentStyle(this, this._styleName);
                    this._isStyleChange = false;
                }
                this.updateStyle();
            }
            if (isInvalid(InvalidationType.DATA))
            {
                this.updateDate();
            }
            if (isInvalid(InvalidationType.SIZE))
            {
                this.updateSize();
            }
            if (isInvalid(InvalidationType.SCROLL))
            {
            }
            if (isInvalid(InvalidationType.ALL))
            {
                this.updateDisplayList();
            }
            try
            {
                super.draw();
            }
            catch (e:Error)
            {
            }
            return;
        }// end function

        protected function createChildren() : void
        {
            return;
        }// end function

        protected function updateStyle() : void
        {
            return;
        }// end function

        protected function updateSize() : void
        {
            return;
        }// end function

        protected function updateDate() : void
        {
            return;
        }// end function

        protected function updateDisplayList() : void
        {
            return;
        }// end function

        public function setScrollBarSize(param1:Number) : void
        {
            _horizontalScrollBar.setSize(param1, height);
            _verticalScrollBar.setSize(param1, height);
            return;
        }// end function

        override protected function drawLayout() : void
        {
            super.drawLayout();
            this.setVerticalScrollBarPosition();
            return;
        }// end function

        public function setVerticalScrollBarWidth(param1:Number) : void
        {
            this.verticalScrollBarWidth = param1;
            return;
        }// end function

        public function set verticalScrollBarPos(param1:String) : void
        {
            this.verticalScrollBarPosition = param1 != SCROLLBARPOSITIONLEFT ? (SCROLLBARPOSITIONRIGHT) : (SCROLLBARPOSITIONLEFT);
            invalidate(InvalidationType.SCROLL);
            return;
        }// end function

        private function setVerticalScrollBarPosition() : void
        {
            if (vScrollBar)
            {
                if (this.verticalScrollBarPosition == SCROLLBARPOSITIONRIGHT)
                {
                    _verticalScrollBar.x = width - this.verticalScrollBarWidth;
                }
                else
                {
                    _verticalScrollBar.x = 0;
                    contentClip.x = contentClip.x + this.verticalScrollBarWidth;
                }
            }
            _verticalScrollBar.visible = vScrollBar;
            return;
        }// end function

        public function configEventListener(param1:String, param2:Function, param3:Boolean = false, param4:int = 0, param5:Boolean = false) : void
        {
            ObjEventListerTool.addObjEvent(this, param1, param2, param3);
            addEventListener(param1, param2, param3, param4, param5);
            return;
        }// end function

        override public function removeEventListener(param1:String, param2:Function, param3:Boolean = false) : void
        {
            ObjEventListerTool.removeObjEvent(this, param1, param2, param3);
            super.removeEventListener(param1, param2, param3);
            return;
        }// end function

        public function set isDisposed(param1:Boolean) : void
        {
            this._isDisposed = param1;
            return;
        }// end function

        public function dispose(param1:Boolean = true) : void
        {
            var _loc_3:int = 0;
            var _loc_4:DisplayObject = null;
            if (this._isDisposed && param1)
            {
                if (Global.isDebugModle)
                {
                    Alert.show("存在组件二次释放" + this.toString());
                }
                return;
            }
            ObjEventListerTool.delObjEvent(this);
            this.verticalScrollBarWidth = 15;
            this.verticalScrollBarPosition = SCROLLBARPOSITIONRIGHT;
            var _loc_2:* = this.numChildren;
            _loc_3 = _loc_2 - 1;
            while (_loc_3 >= 0)
            {
                
                _loc_4 = this.getChildAt(_loc_3);
                if (_loc_4 is IDispose)
                {
                    this.removeChild(_loc_4);
                    (_loc_4 as IDispose).dispose(param1);
                }
                _loc_3 = _loc_3 - 1;
            }
            if (this.parent)
            {
                this.parent.removeChild(this);
            }
            if (param1)
            {
                UICompomentPool.disposeUICompoment(this);
            }
            return;
        }// end function

    }
}
